package com.zlc.workflow.constant;

import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum EventTimeEnum {

    EVENT_PROCESS_START("PROCESS_START","流程启动事件"),
    EVENT_PROCESS_END("PROCESS_END","流程结束事件"),
    EVENT_PROCESS_TERMINATION("PROCESS_TERMINATION","流程终止事件"),
    EVENT_PROCESS_CANCEL("PROCESS_CANCEL","流程撤销事件"),
    EVENT_TASK_ARRIVE("TASK_ARRIVE","任务到达事件"),
    EVENT_TASK_END("TASK_END","任务结束事件"),
    EVENT_TASK_BE_REJECT("TASK_BE_REJECT","任务被退回事件"),
    EVENT_REJECT_NOW_TASK("REJECT_NOW_TASK","退回当前任务事件"),
    ;

    private String type;
    private String desc;

    public static EventTimeEnum  getType(String type){
        EventTimeEnum[] types = values();
        for(EventTimeEnum nodeType : types){
            if(nodeType.type.equals(type)){
                return nodeType;
            }
        }
        return null;
    }

    public static boolean isProcessType(String type){
        return EventTimeEnum.EVENT_PROCESS_START.type.equals(type) ||
                EventTimeEnum.EVENT_PROCESS_END.type.equals(type) ||
                EventTimeEnum.EVENT_PROCESS_TERMINATION.type.equals(type) ||
                EventTimeEnum.EVENT_PROCESS_CANCEL.type.equals(type);
    }
}
